


#     111.二叉树的最小深度



from collections import deque

class TreeNode():
    def __init__(self,value):
        self.element = value
        self.right = None
        self.left = None

class Tree():

    def __init__(self):
        self.root = None


    def minDepth(self, root):
        if root==None:
            return 0
        leftDeep = self.minDepth(root.left)
        rightDeep = self.minDepth(root.right)
        # 必须是左右子树全空 才能算叶子结点 只要有一个不空则继续往下找
        if root.right==None and root.left!=None:
            return leftDeep+1
        if root.right!=None and root.left==None:
            return rightDeep+1
        result = min(leftDeep,rightDeep)+1
        return result




